home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / KoDocumentChild.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-30  |  5.8 KB  |  181 lines

  1. /* This file is part of the KDE project
  2.    Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
  3.  
  4.    This library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public
  6.    License as published by the Free Software Foundation; either
  7.    version 2 of the License, or (at your option) any later version.
  8.  
  9.    This library is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    Library General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU Library General Public License
  15.    along with this library; see the file COPYING.LIB.  If not, write to
  16.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.  * Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef __koDocumentChild_h__
  20. #define __koDocumentChild_h__
  21.  
  22. #include <KoChild.h>
  23. #include <koffice_export.h>
  24. class QDomDocument;
  25. class QDomElement;
  26. class KURL;
  27. class KoStore;
  28. class KoDocument;
  29. class KoDocumentChildPrivate;
  30. class KoDocumentEntry;
  31. class KoXmlWriter;
  32.  
  33. /**
  34.  * @brief Holds an embedded object.
  35.  *
  36.  * In addition to its base class @ref KoChild it cares about the content
  37.  * of an embedded document. That means it supports operations like
  38.  * loading and saving.
  39.  *
  40.  * If you need a representation for embedded documents in your KOffice
  41.  * component then you should inherit from this class.
  42.  */
  43. class KOFFICECORE_EXPORT KoDocumentChild : public KoChild
  44. {
  45.   Q_OBJECT
  46. public:
  47.   KoDocumentChild( KoDocument* parent, KoDocument* doc, const QRect& geometry );
  48.  
  49.   /**
  50.    * When using this constructor you must call @ref #setDocument before
  51.    * you can call any other function of this class.
  52.    */
  53.   KoDocumentChild( KoDocument* parent );
  54.  
  55.   virtual ~KoDocumentChild();
  56.  
  57.   /**
  58.    * Call this function only directly after calling the constructor
  59.    * that takes only a parent as argument.
  60.    */
  61.   virtual void setDocument( KoDocument *doc, const QRect &geometry );
  62.  
  63.   /**
  64.    * @return document contained in this child
  65.    *
  66.    * @see KoDocument
  67.    */
  68.   KoDocument *document() const;
  69.  
  70.   /**
  71.    * @return parent document of this child
  72.    *
  73.    * @see KoDocument
  74.    */
  75.   virtual KoDocument *parentDocument() const; // TODO: remove virtual, makes no sense
  76.  
  77.   virtual KoDocument* hitTest( const QPoint& p, const QWMatrix& _matrix = QWMatrix() );
  78.  
  79.   /**
  80.    * @note Can be empty (which is why it doesn't return a const KURL &)
  81.    */
  82.   KURL url() const;
  83.  
  84.   /**
  85.    *  Writes the "object" tag, but does NOT write the content of the
  86.    *  embedded documents. Saving the embedded documents themselves
  87.    *  is done in @ref KoDocument::saveChildren. This function just stores information
  88.    *  about the position and id of the embedded document and should be
  89.    *  called from within KoDocument::saveXML.
  90.    *
  91.    *  The "object" element is not added to the document. It is just created
  92.    *  and returned.
  93.    *
  94.    *  @return the element containing the "object" tag.
  95.    */
  96.   virtual QDomElement save( QDomDocument& doc, bool uppercase=false );
  97.  
  98.   /**
  99.    * Save an embedded object to OASIS.
  100.    * This method sets the attributes for the draw:object element in the parent XML document.
  101.    * It also prepares the embedded object for being saved into the store at
  102.    * the end of saving (see saveOasisToStore).
  103.    * Note that @p name is only used for "internal" documents (not extern).
  104.    */
  105.   void saveOasisAttributes( KoXmlWriter &xmlWriter, const QString& name );
  106.  
  107.   /**
  108.    * Save an embedded object to an OASIS store.
  109.    * This is called automatically by the parent KoDocument's saveOasis
  110.    */
  111.   virtual bool saveOasis( KoStore* store, KoXmlWriter* manifestWriter );
  112.  
  113.   /**
  114.    *  Parses the "object" tag. This does NOT mean creating the child documents.
  115.    *  AFTER the 'parser' has finished parsing, you must use @ref #loadDocument
  116.    *  to actually load the embedded documents.
  117.    *
  118.    *  What you should have in mind is that this method is called from within
  119.    *  @ref KoDocument::loadXML while @ref #loadDocument is called from within
  120.    *  @ref KoDocument::loadChildren, respectively from your implementation
  121.    *  of these methods.
  122.    */
  123.   virtual bool load( const QDomElement& element, bool uppercase=false );
  124.  
  125.   void loadOasis( const QDomElement &frameElement, const QDomElement& objectElement );
  126.  
  127.   /**
  128.    *  Actually loads the document from the disk/net or from the store,
  129.    *  depending on @ref #url
  130.    */
  131.   virtual bool loadDocument( KoStore* );
  132.  
  133.   /**
  134.    *  Actually loads the document from the disk/net or from the store
  135.    *  depending on the document's url
  136.    */
  137.   virtual bool loadOasisDocument( KoStore* store, const QDomDocument& manifestDoc );
  138.  
  139.   virtual bool isStoredExtern() const;
  140.  
  141.   /**
  142.    * This document (child) is deleted.
  143.    */
  144.   bool isDeleted() const;
  145.   void setDeleted( bool on = true );
  146.  
  147. protected: // Should be private, but KWord needs access to the variables
  148.     // because it reimplements load/save (for uppercase tags)
  149.  
  150.   /**
  151.    *  Holds the source of this object, for example "file:/home/weis/image.gif"
  152.    *  or "tar:/table1/2" if it is stored in a koffice store. This variable is
  153.    *  set after parsing the OBJECT tag in @ref #load and is reset after
  154.    *  calling @ref #loadDocument.
  155.    */
  156.   QString m_tmpURL;
  157.  
  158.   /**
  159.    * This variable is
  160.    *  set after parsing the OBJECT tag in @ref #load and is reset after
  161.    *  calling @ref #loadDocument.
  162.    */
  163.   QRect m_tmpGeometry;
  164.  
  165.   /**
  166.    * This variable is
  167.    *  set after parsing the OBJECT tag in @ref #load and is reset after
  168.    *  calling @ref #loadDocument.
  169.    */
  170.   QString m_tmpMimeType;
  171.  
  172. private:
  173.   bool createUnavailDocument( KoStore* store, bool doOpenURL, const QString& mimeType );
  174.   bool loadDocumentInternal( KoStore* _store, const KoDocumentEntry& e, bool doOpenURL, bool oasis );
  175.  
  176. private:
  177.   KoDocumentChildPrivate *d;
  178. };
  179.  
  180. #endif
  181.